#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/resource.h>


void* thread1(void* arg)
{
    while(1)
    {
        sleep(1);
    }
    return NULL;
}

void init_coredump(void)
{
    chdir("/data/snow");

    struct rlimit limit;
    limit.rlim_cur = RLIM_INFINITY;
    limit.rlim_max = RLIM_INFINITY;

    if (setrlimit(RLIMIT_CORE, &limit) == -1) {
        printf("Failed to set core file size limit\n");
    }else{
        char cwd[PATH_MAX];
        getcwd(cwd, sizeof(cwd));
        printf("coredump inited success, cwd:%s pid:%d\n", cwd, getpid());
    }
}

int main()
{
    init_coredump();

    pthread_t thread;
    pthread_create(&thread, NULL, thread1, NULL);

    while(1)
    {
        sleep(1);
    }
    return 0;
}